//
//  UserDBTool.m
//  StockWin
//
//  Created by showshaw on 15/11/18.
//  Copyright © 2015年 ZhongQian. All rights reserved.
//

#import "UserDBTool.h"

@implementation UserDBTool
//
//+(void)initialize
//{
//    if ([[DataBase sharedDataBase] open]) {
//        // 2.创表
//        //用户信息表
//        NSString * userInfo = @"CREATE TABLE IF NOT EXISTS User_Info (ID INTEGER PRIMARY KEY AUTOINCREMENT,userID INTEGER,userInfo text);";
//        [[DataBase sharedDataBase] executeUpdate:userInfo];
//    };
//}
///**
// *  保存用户信息
// */
//+(BOOL)saveUserInfoWithUserID:(NSInteger)userID userInfo:(PersonInfo*)userInfo
//{
//    NSString * sql;
//    NSString * userInfoJson = userInfo.mj_JSONString;
//    if (![UserDBTool userInfoWithUserID:userInfo.userID]) {    //不存在,插入
//        sql = [NSString stringWithFormat:@"INSERT INTO User_Info(userID,userInfo) VALUES ('%ld','%@');",userID,userInfoJson];
//    }
//    else{
//        sql = [NSString stringWithFormat:@"update User_Info set userInfo = '%@' where userID = '%ld';",userInfoJson,userID];
//    }
//    return [[DataBase sharedDataBase] executeUpdate:sql];
//}
//
///**
// *  获取存储用户缓存信息
// */
//+(PersonInfo*)userInfoWithUserID:(NSUInteger)userID
//{
//    [PersonInfo mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
//        return @{
//                 @"userID":@"userId",
//                 @"basicInfo":@"basic",
//                 @"countInfo":@"count"
//                 };
//    }];
//    
//    NSString * query = [NSString stringWithFormat:@"select * from User_Info where userID = '%ld';",userID];
//    FMResultSet * result = [[DataBase sharedDataBase] executeQuery:query];
//    PersonInfo * person;
//    while ([result next]) {
//        person = [PersonInfo mj_objectWithKeyValues:[result stringForColumn:@"userInfo"]];
//    }
//    return person;
//}

@end
